package com.example.hfweather.ui.home

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

class HorizontalSpaceItemDecoration(private val space: Int, val context: RecyclerView) : RecyclerView.ItemDecoration() {
    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) = with(outRect) {
        super.getItemOffsets(outRect, view, parent, state)
        //获取当前item的position
        val position = parent.getChildAdapterPosition(view)
        if (position == 0) {
            outRect.left = space/2

        } else {
            outRect.left =space


        }
    }
}
